package com.project.poetry.service.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.poetry.common.anno.CanOperation;
import com.project.poetry.service.entity.dto.notes.AllusionInDTO;
import com.project.poetry.service.entity.dto.notes.AllusionOutDTO;
import com.project.poetry.service.entity.dto.notes.AllusionPoetryDTO;
import com.project.poetry.service.entity.dto.notes.NotesDTO;
import com.project.poetry.service.service.NotesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 注释控制器
 * @author mengxj
 */
@Api("注释")
@RestController
@RequestMapping("notes")
public class NotesController {

    @Resource
    private NotesService notesService;

    @CanOperation("保存注释")
    @ApiOperation("保存注释")
    @PostMapping("saveNotes")
    public void saveNotes(@RequestBody NotesDTO notes){
        this.notesService.saveNotes(notes);
    }

    @ApiOperation("根据作品查注释")
    @GetMapping("notesList")
    public List<NotesDTO> notesList(@RequestParam(value = "poetryId", required = false) Long poetryId){
        return this.notesService.notesList(poetryId);
    }

    @ApiOperation("典故查询")
    @GetMapping("allusionList")
    public IPage<AllusionOutDTO> allusionList(AllusionInDTO allusion){
        return this.notesService.allusionList(allusion);
    }

    @ApiOperation("查询带有典故的作品")
    @GetMapping("allusionPoetry")
    public List<AllusionPoetryDTO> allusionPoetry(){
        return this.notesService.allusionPoetry();
    }
}
